<?php
/*********************************************************************
 * ADVERTISEMENT-UPDATE CONTROLLER
 * 
 * Author: hthieu1110
 * Date: 12/04/2011 (generated automatically)
*********************************************************************/
require_once dirname(realpath(__FILE__))."./../../config/config.inc.php";

$args = sessionGetVar('args');
$advertisementId = sessionGetVar('id');

if($_POST['action'] == 'update') {
	try {
		$advertisement = new Advertisement($advertisementId);
		
		//add advertisement
		$advertisement->update($args);
		sessionSetVar('success', 'Your advertisement is updated successfully.');
		header('Location:/success.php');
		exit();
	} catch (Exception $e) {
		sessionSetVar('error', 'Unable to update this advertisement.'.$e->getMessage());
		header('Location:/error.php');
		exit();
	}
}

$cssNames = array("advertisement-update");

require_once VIEW_PATH."header.inc.php";
require_once VIEW_PATH."/advertisement-update.inc.php";
require_once VIEW_PATH."footer.inc.php";
?>